package org.tgcloud.group.core;

import lombok.Getter;

/**
 * 项目阶段枚举
 * @Author zhy
 * @Created 2025-10-28
 */
@Getter
public enum ProjectStatusEnum {

    CREATE("create", "创建中"),
    WAIT_SELECTION_PRICING("waitSelectionPricing", "待选品核价"),
    WAIT_SELECTION_FEEDBACK("waitSelectionFeedback", "待选品反馈"),
    WAIT_PACKAGE("waitPackage", "待配包"),
    PACKAGE_CONFIRMING("packageConfirming", "配包确认中"),
    CONTRACTING("contracting", "合同中"),
    SIGNED("signed", "已签单"),
    WAIT_RECEIVE("waitReceive", "待收货"),
    WAIT_EXECUTION("waitExecution", "待执行"),
    EXECUTING("executing", "执行中"),
    EXECUTED("executed", "执行完"),
    FAILED("failed", "黄单");

    /** 状态英文code（小驼峰） */
    private final String code;

    /** 状态中文名称 */
    private final String name;

    ProjectStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据 code 获取枚举
     */
    public static ProjectStatusEnum getByCode(String code) {
        if (code == null) return null;
        for (ProjectStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }

    /**
     * 根据 name 获取枚举
     */
    public static ProjectStatusEnum getByName(String name) {
        if (name == null) return null;
        for (ProjectStatusEnum status : values()) {
            if (status.name.equals(name)) {
                return status;
            }
        }
        return null;
    }
}
